/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

export function delay(then, timer) {
  const list = [0, 500, 1000, 2000, 3000];
  return setTimeout(then, timer || list[parseInt(Math.random() * list.length)]);
}

export function randomValue(list) {
  return list[parseInt(Math.random() * list.length)];
}

export function randomOrderDetail() {
  const goodsList = [
    '日用品',
    '数码产品',
    '衣物',
    '食物',
    '文件',
    '自定义',
    '生鲜：鲫鱼',
    '生鲜：水果',
  ];
  const state = [
    { status: '2', text: '已完成' },
    { status: '1', text: '未完成' },
    { status: '3', text: '已打印' },
    { status: '4', text: '已取消' },
  ];
  const brands = [
    { brand: 'sto', short_name: '申通' },
    { brand: 'zt', short_name: '中通' },
    { brand: 'yt', short_name: '圆通' },
    { brand: 'yd', short_name: '韵达' },
    { brand: 'post', short_name: '邮政' },
  ];
  const isRealnames = ['已实名', '未实名'];
  const orderCategorys = ['orderDak', 'orderWkd'];
  const goodsType = randomValue(goodsList);
  const { status, text: statusText } = randomValue(state);
  const { brand, short_name } = randomValue(brands);
  const isRealname = randomValue(isRealnames);
  const orderCategory = randomValue(orderCategorys);
  return {
    goodsType,
    status,
    statusText,
    brand,
    short_name,
    isRealname,
    orderCategory,
  };
}
